<template>
  <main class="supplier-system">
    <div class="min-pc-width system">
      <p class="header"><span>第1页</span></p>
      <!-- <a-form :form="form" @submit="handleSubmit"> -->
      <a-form :form="form" @submit="handleSubmit">
        <a-form-item label="成果名称" class="form-item mt60">
          <a-input v-decorator="['cgmch',{ initialValue: formData.cgmch || '' , rules: [{ required: true, message: '成果名称不能为空!' }]}]" placeholder="成果名称" autocomplete="off" />
        </a-form-item>
        <a-form-item label="成果类型" class="form-item">
          <a-select v-decorator="['cglx',{initialValue: formData.cglx || '1', rules: [{ required: true, message: '请选择成果类型!' }]}]" placeholder="成果类型" >
            <a-select-option value="1">科研成果</a-select-option>
            <a-select-option value="2">BIM成果</a-select-option>>
          </a-select>
        </a-form-item>
        <a-form-item label="完成单位" class="form-item">
          <a-input v-decorator="['wcdw',{ initialValue: formData.wcdw || '' ,rules: [{ required: true, message: '完成单位不能为空!' }]}]" placeholder="完成单位" autocomplete="off" />
        </a-form-item>
        <a-form-item label="申报单位名称" class="form-item">
          <a-input v-decorator="['dwmch',{ initialValue: formData.dwmch || '' ,rules: [{ required: true, message: '单位名称不能为空!' }]}]" placeholder="单位名称" autocomplete="off" />
        </a-form-item>
        <a-form-item label="申报单位-联系人" class="form-item">
          <a-input v-decorator="['lxren',{ initialValue: formData.lxren || '' ,rules: [{ required: true, message: '联系人不能为空!' }]}]" placeholder="联系人" autocomplete="off" />
        </a-form-item>
        <a-form-item label="联系电话" class="form-item">
          <a-input v-decorator="['lxdhua',{ initialValue: formData.lxdhua || '' ,rules: [{ required: true, message: '联系电话不能为空!' }]}]" placeholder="联系电话" autocomplete="off" />
        </a-form-item>
        <!-- <p class="content mt20">成果研发负责人 </p>
        <a-form-item label="姓名" class="form-item">
          <a-input v-decorator="['xming',{ initialValue: formData.xming || '' ,rules: [{ required: true, message: '姓名不能为空!' }]}]" placeholder="姓名" autocomplete="off" />
        </a-form-item>
        <a-form-item label="联系方式" class="form-item">
          <a-input v-decorator="['lxfangshi',{ initialValue: formData.lxfangshi || '' ,rules: [{ required: true, message: '联系方式不能为空!' }]}]" placeholder="联系方式" autocomplete="off" />
        </a-form-item>
        <a-form-item label="依托工程项目名称" class="form-item">
          <a-input v-decorator="['ytxmmch',{ initialValue: formData.ytxmmch || '' ,rules: [{ required: true, message: '依托工程项目名称不能为空!' }]}]" placeholder="依托工程项目名称" autocomplete="off" />
        </a-form-item> -->
        <a-form-item label="主要完成人" class="form-item">
          <a-input v-decorator="['mainrens',{ initialValue: formData.mainrens || '' ,rules: [{ required: true, message: '主要完成人不能为空!' }]}]" placeholder="主要完成人" autocomplete="off" />
        </a-form-item>
        <div class="split">
          <span class="line"></span>
          <span class="text">成果简介</span>
          <span class="line"></span>
        </div>
        <a-form-item label="" class="form-item">
          <a-textarea  v-decorator="['cgjiejian',{initialValue: formData.cgjiejian || '' }]" placeholder="150字以内" :rows="10" autocomplete="off" />
        </a-form-item>
        <!-- <p class="content mt20">成果评价及专利情况 </p> -->
        <!-- <a-form-item label="企业技术部门认定" class="form-item">
          <a-input v-decorator="['qyjsbumenrd',{ initialValue: formData.qyjsbumenrd || '' , rules: [{ required: true, message: '企业技术部门认定不能为空!' }]}]" placeholder="企业技术部门认定" />
        </a-form-item>
        <a-form-item label="市科委认定" class="form-item">
          <a-input v-decorator="['skwrd',{ initialValue: formData.skwrd || '' , rules: [{ required: true, message: '市科委认定不能为空!' }]}]" placeholder="市科委认定" />
        </a-form-item>
        <a-form-item label="专利情况" class="form-item">
          <a-input v-decorator="['zliqkuan',{ initialValue: formData.zliqkuan || '' , rules: [{ required: true, message: '专利情况不能为空!' }]}]" placeholder="专利情况" />
        </a-form-item> -->
        <a-form-item label="成果评价及专利情况" class="form-item">
          <a-row>
            <a-col :span="8">
              <a-checkbox v-model="qyjsbumenrd">企业认定</a-checkbox>
            </a-col>
            <a-col :span="8">
              <a-checkbox v-model="gczjrd">协会认定</a-checkbox>
            </a-col>
            <a-col :span="8">
              <a-checkbox v-model="sjdwjsbmrd">上级单位认定</a-checkbox>
            </a-col>
            <a-col :span="8">
              <a-checkbox v-model="skwrd">市科委认定</a-checkbox>
            </a-col>
            <a-col :span="8">
              <a-checkbox v-model="zliqkuan">专利情况</a-checkbox>
            </a-col>
          </a-row>
        </a-form-item>
        <p class="content mt20">BIM成果应用及创新性评价 </p>
        <div class="split">
          <span class="line"></span>
          <span class="text">项目应用证明</span>
          <span class="line"></span>
        </div>
        <a-form-item label="" class="form-item">
          <a-textarea  v-decorator="['xmyyongzm',{ initialValue: formData.xmyyongzm || '' ,}]" placeholder="300字以内" :rows="10" autocomplete="off" />
        </a-form-item>
        <a-form-item label="企业BIM主管部门创新性评价" class="form-item">
          <a-input v-decorator="['bimzgbmpingjia',{  initialValue: formData.bimzgbmpingjia || '' ,rules: [{ required: true, message: '企业BIM主管部门创新性评价不能为空!' }]}]" placeholder="企业BIM主管部门创新性评价" />
        </a-form-item>
        <a-form-item label="单位自审意见" class="form-item">
          <a-input v-decorator="['dwzsyijian',{  initialValue: formData.dwzsyijian || '' ,rules: [{ required: true, message: '单位自审意见不能为空!' }]}]" placeholder="单位自审意见" />
        </a-form-item>
        <div class="supplier-footer">
          <a-button class="s-btn" html-type="submit"  @click="save">
          <!-- <a-button html-type="submit" class="s-btn"> -->
            保存
          </a-button>
          <a-button @click="resetForm" class="s-btn">
            重填
          </a-button>
          <a-button  type="primary" html-type="submit"  @click="goNext" class="s-btn">
            继续
          </a-button>
        </div>
    </a-form>
    </div>
  </main>
</template>
<script>
export default {
  data () {
    return {
      currentIndex: 0,
      form: this.$form.createForm(this),
      formId: '',
      formData: '',
      headers: {
        authorization: 'authorization-text'
      },
      type: 0,
      uploadUrl: `${process.env.VUE_APP_URL}/main/upload`,
      lxrwfile: '',
      jsbgaofile: '',
      cgjdzsfile: '',
      yyzmxyzmfile: '',
      zscqzmfile: '',
      hjzmfile: '',
      bimyyzjiefile: '',
      mxwjmlfile: '',
      xiaoyizmfile: '',
      huojiazmfile: '',
      qyjsbumenrd: false,
      gczjrd: false,
      sjdwjsbmrd: false,
      skwrd: false,
      zliqkuan: false
    }
  },
  components: {
  },
  computed: {
  },
  created () {
    if (this.$route.query.id) {
      this.formId = this.$route.query.id
      this.getKJCXFormDataById()
    }
  },
  methods: {
    goBack () {
      this.$router.go(-1)
    },
    goNext () {
      this.type = 1
    },
    save () {
      this.type = 0
    },
    memberStepForm (values) {
      this.$http.submitKJCXForm(Object.assign(values, {
        id: this.formId,
        qyjsbumenrd: this.qyjsbumenrd,
        gczjrd: this.gczjrd,
        sjdwjsbmrd: this.sjdwjsbmrd,
        skwrd: this.skwrd,
        zliqkuan: this.zliqkuan
      })).then(res => {
        this.formId = res.data.id
        if (this.type == 1) {
          this.$router.push({ path: `/innovation/create/2?id=${res.data.id}` })
        }
      })
    },
    getKJCXFormDataById () {
      this.$http.getKJCXFormDataById({ id: this.formId }).then(res => {
        Object.keys(v => {
          this.$set(this.formData, v, res.data[v])
        })
        this.formData = res.data
        this.qyjsbumenrd = res.data.qyjsbumenrd || false
        this.gczjrd = res.data.gczjrd || false
        this.sjdwjsbmrd = res.data.sjdwjsbmrd || false
        this.skwrd = res.data.skwrd || false
        this.zliqkuan = res.data.zliqkuan || false
      })
    },
    handleSubmit (e) {
      let _this = this
      e.preventDefault()
      this.form.validateFields((err, values) => {
        if (!err) {
          _this.memberStepForm(values)
        }
      })
    },
    resetForm () {
      this.form.resetFields()
    }
  }
}
</script>
<style lang="scss">
</style>
